package org.ycx.upms.dao.auto;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.ycx.upms.dao.model.SecPermission;
import org.ycx.upms.dao.model.SecPermissionExample;

import java.util.List;

public interface SecPermissionMapper {
    @SelectProvider(type=SecPermissionSqlProvider.class, method="countByExample")
    long countByExample(SecPermissionExample example);

    @DeleteProvider(type=SecPermissionSqlProvider.class, method="deleteByExample")
    int deleteByExample(SecPermissionExample example);

    @Delete({
        "delete from sec_permission",
        "where PERMISSION_ID = #{permissionId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer permissionId);

    @Insert({
        "insert into sec_permission (PERMISSION_ID, NAME, ",
        "CATEGORY, VALUE, ",
        "URI, ICON, STATE, ",
        "PID, ORDERS, OTHER, ",
        "CREATE_TS, CREATE_UID, ",
        "UPDATE_TS, UPDATE_UID)",
        "values (#{permissionId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{category,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR}, ",
        "#{uri,jdbcType=VARCHAR}, #{icon,jdbcType=VARCHAR}, #{state,jdbcType=VARCHAR}, ",
        "#{pid,jdbcType=INTEGER}, #{orders,jdbcType=INTEGER}, #{other,jdbcType=VARCHAR}, ",
        "#{createTs,jdbcType=DATE}, #{createUid,jdbcType=INTEGER}, ",
        "#{updateTs,jdbcType=DATE}, #{updateUid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="systemId", before=false, resultType=Integer.class)
    int insert(SecPermission record);

    @InsertProvider(type=SecPermissionSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="systemId", before=false, resultType=Integer.class)
    int insertSelective(SecPermission record);

    @SelectProvider(type=SecPermissionSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="PERMISSION_ID", property="permissionId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="SYSTEM_ID", property="systemId", jdbcType=JdbcType.INTEGER),
        @Result(column="NAME", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="CATEGORY", property="category", jdbcType=JdbcType.VARCHAR),
        @Result(column="VALUE", property="value", jdbcType=JdbcType.VARCHAR),
        @Result(column="URI", property="uri", jdbcType=JdbcType.VARCHAR),
        @Result(column="ICON", property="icon", jdbcType=JdbcType.VARCHAR),
        @Result(column="STATE", property="state", jdbcType=JdbcType.VARCHAR),
        @Result(column="PID", property="pid", jdbcType=JdbcType.INTEGER),
        @Result(column="ORDERS", property="orders", jdbcType=JdbcType.INTEGER),
        @Result(column="OTHER", property="other", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    List<SecPermission> selectByExample(SecPermissionExample example);

    @Select({
        "select",
        "PERMISSION_ID, SYSTEM_ID, NAME, CATEGORY, VALUE, URI, ICON, STATE, PID, ORDERS, ",
        "OTHER, CREATE_TS, CREATE_UID, UPDATE_TS, UPDATE_UID",
        "from sec_permission",
        "where PERMISSION_ID = #{permissionId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="PERMISSION_ID", property="permissionId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="SYSTEM_ID", property="systemId", jdbcType=JdbcType.INTEGER),
        @Result(column="NAME", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="CATEGORY", property="category", jdbcType=JdbcType.VARCHAR),
        @Result(column="VALUE", property="value", jdbcType=JdbcType.VARCHAR),
        @Result(column="URI", property="uri", jdbcType=JdbcType.VARCHAR),
        @Result(column="ICON", property="icon", jdbcType=JdbcType.VARCHAR),
        @Result(column="STATE", property="state", jdbcType=JdbcType.VARCHAR),
        @Result(column="PID", property="pid", jdbcType=JdbcType.INTEGER),
        @Result(column="ORDERS", property="orders", jdbcType=JdbcType.INTEGER),
        @Result(column="OTHER", property="other", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATE_TS", property="createTs", jdbcType=JdbcType.DATE),
        @Result(column="CREATE_UID", property="createUid", jdbcType=JdbcType.INTEGER),
        @Result(column="UPDATE_TS", property="updateTs", jdbcType=JdbcType.DATE),
        @Result(column="UPDATE_UID", property="updateUid", jdbcType=JdbcType.INTEGER)
    })
    SecPermission selectByPrimaryKey(Integer permissionId);

    @UpdateProvider(type=SecPermissionSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") SecPermission record, @Param("example") SecPermissionExample example);

    @UpdateProvider(type=SecPermissionSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") SecPermission record, @Param("example") SecPermissionExample example);

    @UpdateProvider(type=SecPermissionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SecPermission record);

    @Update({
        "update sec_permission",
        "set SYSTEM_ID = #{systemId,jdbcType=INTEGER},",
          "NAME = #{name,jdbcType=VARCHAR},",
          "CATEGORY = #{category,jdbcType=VARCHAR},",
          "VALUE = #{value,jdbcType=VARCHAR},",
          "URI = #{uri,jdbcType=VARCHAR},",
          "ICON = #{icon,jdbcType=VARCHAR},",
          "STATE = #{state,jdbcType=VARCHAR},",
          "PID = #{pid,jdbcType=INTEGER},",
          "ORDERS = #{orders,jdbcType=INTEGER},",
          "OTHER = #{other,jdbcType=VARCHAR},",
          "CREATE_TS = #{createTs,jdbcType=DATE},",
          "CREATE_UID = #{createUid,jdbcType=INTEGER},",
          "UPDATE_TS = #{updateTs,jdbcType=DATE},",
          "UPDATE_UID = #{updateUid,jdbcType=INTEGER}",
        "where PERMISSION_ID = #{permissionId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SecPermission record);
}